<?
require_once("mvc/action/Action.php");
require_once("cms/guide/om/GuideI18nPeer.php");

class EditAction extends Action {

    private $log;

    public function __construct() {
        $this->log =& LoggerManager::getLogger("EditAction");
    }

    public function execute(ActionConfig &$mapping, &$form, Request &$request, Response &$response) {

        if($form->getGuideI18n()->getGuideI18nId() > 0) {

            $guideI18n = GuideI18nPeer::retrieveByPk($form->getGuideI18n()->getGuideI18nId());
            if(!is_null($guideI18n)) {

                $form->setGuideI18n($guideI18n);

            } else {
                $this->log->error("No guideI18n found with id {$form->getGuideI18n()->getGuideI18nId()}.");
                $form->getGuideI18n()->setGuideI18nId("");

                if($form->getGuideI18n()->getLanguageCode() === null)
                    $form->getGuideI18n()->setLanguageCode(
                        $request->getContext()->getInitParameter(_Core::DEFAULT_LANGUAGE)
                    );
            }

        } else {

            if($form->getGuideI18n()->getLanguageCode() === null)
                $form->getGuideI18n()->setLanguageCode(
                    $request->getContext()->getInitParameter(_Core::DEFAULT_LANGUAGE)
                );

        }

        return $mapping->findForward("success");

    }

}
?>